import request from "@/util/request";
enum API {
    SECTION = "/share/set/section",
    SECTION_PAGE = "/share/set/section/page",
    SECTION_ORDER_ADJUST = "/share/set/section/order/adjust",
}

export function reqGetSectionPage(query: any){
    return request({
        url: API.SECTION_PAGE ,
        method: "get",
        params: query
    });
}
export function reqGetSection(id: number){
    return request({
        url: API.SECTION + "/" + id,
        method: "get",
    });
}
export function reqDeleteSection(id: number){
    return request({
        url: API.SECTION + "/" + id,
        method: "delete",
    });
}
export function reqCreateSection(section: any){
    return request({
        url: API.SECTION,
        method: "post",
        data: section
    });
}
export function reqUpdateSection(section: any){
    return request({
        url: API.SECTION,
        method: "put",
        data: section
    });
}
export function   reqAdjustSectionOrder(data){
    return request({
        url: API.SECTION_ORDER_ADJUST,
        method: "put",
        data
    });
}

// 获取可选视频（排除已关联的）
export const reqGetAvailableVideos = (params: any) => {
    return request({
        url: '/share/video/page',
        method: 'get',
        params
    })
}

// 批量关联视频到章节
export const reqBatchRelateVideos = (data: any) => {
    return request({
        url: '/share/set/section/video/related',
        method: 'post',
        data
    })
}
export const reqBatchDelRelateVideosByIds = (data: any) => {
    return request({
        url: '/share/set/section/video/related/ids',
        method: 'delete',
        data
    })
}
export function reqDeleteSectionVideo(data: any) {
    return request({
        url: '/share/set/section/video/related',
        method: 'delete',
        data
    })
}
export function reqGetSectionRelatedVideoList(sectionId) {
    return request({
        url: '/share/set/section/related/list/'+sectionId,
        method: 'get',
    })
}

// 更新视频顺序
export const reqUpdateVideoOrder = (data: any) => {
    return request({
        url: '/section/update-video-order',
        method: 'post',
        data
    })
}
